﻿Public Class SettingWindow

    Dim _sender As New SinaOAuth("639030757", "22166d80197513347b1b373f723559c0")
    Dim token As String = String.Empty
    Dim secret As String = String.Empty

    Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
        If _sender.GetRequestToken(token, secret) Then
            Try
                Process.Start(_sender.RedirectToAuthorize(token))
            Catch ex As Exception
                MessageBox.Show("不能打开浏览器，打开" + _sender.RedirectToAuthorize(token) + "出错")
            End Try
        End If
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button2.Click
        If _sender.GetAccessToken(token, secret, TextBox1.Text) Then
            My.Settings.Token = token
            My.Settings.TokenSecret = secret
            Label2.Content = "已认证"
        End If
    End Sub
End Class
